import { ref, onMounted } from "vue";
import { GoodList } from "@/request/api";

const goods = ref([]); // 创建响应式引用

onMounted(() => {
    console.log('组件已挂载'); // 确认组件是否挂载
    GoodList({ pageNum: 1, pageSize: 10 })
        .then(res => {
            if (res.code === 0) {
                goods.value = res.result.list;
                console.log(goods.value);
            } else {
                console.error(res.msg);
            }
        })
        .catch(err => {
            console.error('获取商品列表失败', err);
        });
});

// 导出 goods
export { goods };